﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PhotoGallery.Core.Business.Account>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    编辑人员 - 重庆公安图片管理系统
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="con-box">
        <div class="head">
            <h2>
                <%= Html.ActionLink("人员管理", "Index") %>
                &gt; 编辑人员
            </h2>
        </div>
        <div class="con">
           
            <div class="box">
                <% using (Html.BeginForm("Update", "Account", FormMethod.Post, new { id = "mainForm" }))
                   {%>
                <%= Html.HiddenFor(model => model.Id) %>
                <p>
                    <label class="i" for="Name">
                        姓名：
                    </label>
                    <%= Html.TextBoxFor(model => model.Name, new { @class = "text w200", title = "必填项，5字以内", required = "required", maxlength = "5" })%>
                </p>
                <p>
                    <label class="i" for="LoginName">
                        系统登录名：
                    </label>
                    <%= (Model != null) ? Model.LoginName : "" %>
                </p>
                <p>
                    <label class="i" for="Gender">
                        性别：
                    </label>
                    <%= Html.RadioButton("Gender", "0", (Model == null) || (Model.Gender == 0.0m), new { id = "Gender-Female" })%><label
                        for="Gender-Female">女</label>
                    <%= Html.RadioButton("Gender", "1", (Model != null) && (Model.Gender == 1.0m), new { id = "Gender-Male" })%><label
                        for="Gender-Male">男</label>
                </p>
                <p>
                    <label class="i" for="Telephone">
                        联系电话：
                    </label>
                    <%= Html.TextBoxFor(model => model.Telephone, new { @class = "text w200", title = "可留空", pattern=@"(-|[0-9]|,|\s){0,30}" })%>
                </p>               
                <p>
                    <label class="i" for="">
                        出生日期：
                    </label>
                    <% if (Model != null)
                       {
                           Response.Write(Html.DateInput(Model.Birthday, new { @class = "text w80", id = "Birthday", name = "Birthday", title = "可留空", required = "required" }));
                       }
                       else
                       {
                           Response.Write(Html.DateInput(new DateTime?(), new { @class = "text w80", id = "Birthday", name = "Birthday", title = "可留空", required = "required" }));
                       }%>
                </p>
                <p>
                    <label class="i" for="Address">
                        住址：
                    </label>
                    <%= Html.TextAreaFor(model => model.Address, new { rows = "3", @class = "text w300", title = "可留空", maxlength = "100" })%>
                </p>
                
                <div class="action paddingl90">
                    <span class="sexybutton" id="btn-submit"><span><span>
                        <input type="submit" class="save" value="保存" /></span></span></span>
                </div>
                <% } %>
            </div>
        </div>
    </div>
    
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#mainForm input[type='text'],#mainForm input[type='password'],#mainForm textarea").tooltip({
                position: "center right",
                offset: [-2, 5],
                effect: "fade",
                opacity: 0.7
            });
            $("#Birthday").dateinput({ selectors: true });
            $("#mainForm").validator({ lang: 'zh-CN' });

            // 签章
            (function () {
                var isDataValid = false;
                $("#signForm :input").validator({ lang: 'zh-CN' }).bind("onFail", function (e, els) {
                    isDataValid = false;
                }).bind("onSuccess", function () { isDataValid = true; });

                $("#sign-win").css("display", "block");
                var winSign = cy.ui.window('sign-win', {
                    title: '修改签章',
                    width: 500,
                    height: 100,
                    moveable: true,
                    buttons: [{ id: 'ok', name: '确认', clicked: function () {
                        $("#signForm").trigger("submit");

                        if (isDataValid) {
                            $("#signForm").ajaxSubmit({ dataType: 'json', resetForm: true, success: function (data) {
                                if (data.success) {
                                    $("#Sign").attr("src", data.signPath);
                                    winSign.hide();
                                }
                                cy.ui.showResult({ content: data.message, disappear: 5000 });
                            }
                            });
                        } else {
                            cy.ui.showResult({ content: '输入有误', disappear: 2000 });
                        }
                    }, attributes: { className: 'ok' }
                    }, { id: 'cancel', name: '取消', clicked: function () { winSign.hide(); $("#signForm").resetForm(); }, attributes: { className: 'cancel'}}]
                });
                $("a.editSign").click(function () { winSign.show(); });
            })();
        });
    </script>
</asp:Content>
